home *** CD-ROM | disk | FTP | other *** search
/ MacPeople 2003 February 1 / MACPEOPLE-2003-02-01.ISO.7z / MACPEOPLE-2003-02-01.ISO / 特集2/システム環境設定 / Macaroni / Macaroni 1.2.1 Installer / Macaroni 1.2.1 Installer.rsrc / shsc_5001_Uninstall Edit Crontab < prev    next >
Text File  |  2002-12-11  |  1KB  |  49 lines

  1. #!/usr/bin/perl -W
  2.  
  3. # $Id: Macaroni.post_install,v 1.4 2002/09/10 22:54:40 tph Exp $
  4.  
  5. # Uninstall script; undo crontab edits made by the install script.
  6.  
  7. use strict;
  8. use File::Copy;
  9.  
  10. my $DEBUG = 0;
  11. my $ROOT_CRONTAB;
  12. my $TOOL_DIR;
  13. my $TOOL_LINK_DIR;
  14.  
  15. if ($DEBUG) {
  16.     $ROOT_CRONTAB = "/tmp/crontab";
  17. } else {
  18.     $ROOT_CRONTAB = "/etc/crontab";
  19. }
  20. my $TOOL_NAME = "MacaroniTool";
  21.  
  22. # Make a backup copy
  23. my $ROOT_CRONTAB_SAVE = $ROOT_CRONTAB . ".uninstall-save-$TOOL_NAME." . time;
  24. copy ($ROOT_CRONTAB, $ROOT_CRONTAB_SAVE) or die;
  25. # Work on a new copy
  26. my $NEW_CRONTAB = $ROOT_CRONTAB . ".temp." . time;
  27.  
  28. open (CRONTAB, $ROOT_CRONTAB) or die "Couldn't open existing crontab";
  29. open (NEW_CRONTAB, ">$NEW_CRONTAB") or die "Couldn't create new crontab";
  30. while (<CRONTAB>)
  31. {
  32.     # Do nothing on tool lines, so that it'll be deleted.
  33.     next if (/MacaroniTool/);
  34.     # Uncomment lines that the install script modifies.
  35.     if (/etc¥/daily/ || /etc¥/weekly/ || /etc¥/monthly/
  36.             || /periodic daily/ || /periodic weekly/
  37.             || /periodic monthly/) {
  38.         s/^#*//;
  39.         print NEW_CRONTAB;
  40.         next;
  41.     }
  42.     # Print everything else out unmodified.
  43.     print NEW_CRONTAB;
  44. }
  45. close CRONTAB;
  46. close NEW_CRONTAB;
  47. unlink $ROOT_CRONTAB;
  48. move $NEW_CRONTAB, $ROOT_CRONTAB;
  49.